package com.jk.dmpayprovider.djhservice;

import com.jk.dmcommon.LybEntity.UserEntity;
import com.jk.dmcommon.djhEntity.DjhDistrEntity;
import com.jk.dmcommon.djhEntity.DjhWatchPersonEntity;
import com.jk.dmpayprovider.dao.DjhOrderDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DjhOrderService {
    @Autowired
    private DjhOrderDao djhOrderDao;

    @Autowired
    private RedisTemplate redisTemplate;


    public void addPerson(DjhWatchPersonEntity djhWatchPersonEntity) {
        UserEntity user = (UserEntity) redisTemplate.opsForHash().get("dmLoginInfo", "loginInfo");
        djhWatchPersonEntity.setUserId(user.getUserId());
        djhOrderDao.addPerson(djhWatchPersonEntity);
       Integer personId= djhWatchPersonEntity.getPersonId();
        redisTemplate.opsForHash().put("bothPeople", "personId",personId);
    }

    public List<DjhDistrEntity> selectPeisong(Integer goodsId) {
        return djhOrderDao.selectPeisong(goodsId);
    }
    //观影人回显
    public List<DjhWatchPersonEntity> selectAllWatchPerson() {

        UserEntity user = (UserEntity) redisTemplate.opsForHash().get("dmLoginInfo","loginInfo");
        return djhOrderDao.selectAllWatchPerson(user.getUserId());
    }
}
